Middleware in Go is a function that wraps an http.Handler and returns a new http.Handler. This pattern is the same whether using the standard library or frameworks like Gin and Echo.
Standard library: no dependencies, explicit, full control — preferred for simple services
Gin: Use() method chains middleware; request context via gin.Context; fast router with params
Echo: similar to Gin, cleaner API, built-in binder and validator
Chi: 100% compatible with net/http; lightweight router with middleware support
For most APIs: net/http + Chi or stdlib routing (Go 1.22) is sufficient without a full framework